<template>
	<view>

<uni-list>
	<uni-list :border="true">
		<!-- 显示圆形头像 -->
		<uni-list-item  v-for="(item, index) in list" :key="index" :title="item.title" :note="item.author" :rightText="item.date"  clickable  @click="toDetail(item)"></uni-list-item>
		<!-- 右侧带角标 -->

	</uni-list>
</uni-list>


<!-- 		<view  v-for="(item, index) in list" :key="index">
			<text>{{item.title}}</text>
			<text>{{item.author}}</text>
			<text>{{item.date}}</text>
		</view> -->
		<loading
			ref="loading"
			:custom="false"
			:shadeClick="true"
			:type="1"
			>
			<view style="text-align: center;">等待中</view>
		</loading>
	</view>
</template>
<script>
	import loading from '@/components/xuan-loading/xuan-loading.vue'
	export default {
		components: {
			loading
		  },
		async mounted() {
			this.$refs.loading.open();
			let value = uni.getStorageSync('user_info');
			let user_id=value._id
			let a= await this.getPostsByUserId(user_id)
		},
		data() {
			return {
				list:[]
			}
		},
		methods: {
			toDetail(item){
				uni.navigateTo({
					url:"/pages/postDetail/postDetail?item="+encodeURIComponent(JSON.stringify(item))
				})
			},
			getPostsByUserId(id){
				uniCloud.callFunction({
					name: 'getPostsByUserId',
					data: {
							"user_id":id,
					}
				})
				.then(res => {
					let result=res.result
					this.list=result.list
					this.$refs.loading.close();
				});
			
			},
		}
	}
</script>

<style scoped>
	.chat-custom-right {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-end;
	}

	.chat-custom-text {
		font-size: 12px;
		color: #999;
	}

</style>